function $(a) {
  return document.querySelector(a);
}

var userIdmessage = document.getElementById("userIdmessage");

function data() {
  var a, b, c, d, e, f, g;
  axios({
    method: "get",
    url: "/actor/findAllActorMsgLimitPage",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.data.pageTotalCount;
      $(".data").innerHTML += `<p class="actordata" >${pageTotalCount}</p>`;
      d = $(".actordata").innerHTML;
      localStorage.setItem("d", d);
    })
    .catch((err) => {
      console.log(err);
    });
  axios({
    method: "get",
    url: "/user/findAllUser",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.object.pageTotalCount;
      $(".data").innerHTML += `<p class="userdata" >${pageTotalCount}</p>`;
      b = $(".userdata").innerHTML;
      localStorage.setItem("b", b);
    })
    .catch((err) => {
      console.log(err);
    });
  axios({
    method: "get",
    url: "/findAllComment",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.object.pageTotalCount;
      $(".data").innerHTML += `<p class="pinglundata" >${pageTotalCount}</p>`;
      c = $(".pinglundata").innerHTML;
      localStorage.setItem("c", c);
    })
    .catch((err) => {
      console.log(err);
    });

  axios({
    method: "get",
    url: "/videoCRUD/findAllVideo",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.data.pageTotalCount;
      $(".data").innerHTML += `<p class="videodata" >${pageTotalCount}</p>`;
      a = $(".videodata").innerHTML;
      localStorage.setItem("a", a);
    })
    .catch((err) => {
      console.log(err);
    });

  axios({
    method: "get",
    url: "/order/findAllUser",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.object.pageTotalCount;
      $(".data").innerHTML += `<p class="vipdata" >${pageTotalCount}</p>`;
      e = $(".vipdata").innerHTML;
      localStorage.setItem("e", e);
    })
    .catch((err) => {
      console.log(err);
    });

  axios({
    method: "get",
    url: "/advertisement/findAllAdverLimitPage",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.data.pageTotalCount;
      $(
        ".data"
      ).innerHTML += `<p class="advertisementdata" >${pageTotalCount}</p>`;
      f = $(".advertisementdata").innerHTML;
      localStorage.setItem("f", f);
    })
    .catch((err) => {
      console.log(err);
    });

  axios({
    method: "get",
    url: "/payVipOrder/findAllPayVipOrder",
    params: {
      pageNow: 1,
      pageSize: 10,
    },
  })
    .then(function (data) {
      var pageTotalCount = data.data.data.object.pageTotalCount;
      $(".data").innerHTML += `<p class="orderdata" >${pageTotalCount}</p>`;
      g = $(".orderdata").innerHTML;
      localStorage.setItem("g", g);
    })
    .catch((err) => {
      console.log(err);
    });

  var a1 = localStorage.getItem("a");
  var b1 = localStorage.getItem("b");
  var c1 = localStorage.getItem("c");
  var d1 = localStorage.getItem("d");
  var e1 = localStorage.getItem("e");
  var f1 = localStorage.getItem("f");
  var g1 = localStorage.getItem("g");
  var myChart = echarts.init(document.getElementById("main"));
  var myChart1 = echarts.init(document.getElementById("main1"));
  // 指定图表的配置项和数据
  var option = {
    title: {
      text: "后台总数据",
    },
    tooltip: {},
    legend: {
      data: ["数据"],
    },
    xAxis: {
      data: ["视频", "用户", "评论", "演员", "vip商品", "广告", "订单"],
    },
    yAxis: {},
    series: [
      {
        type: "bar",
        data: [a1, b1, c1, d1, e1, f1, g1],
      },
    ],
  };
  //   var option1 = {
  //     series: [
  //         {
  //           type: 'pie',
  //           data: [
  //             {
  //               value: 42,
  //               name: '视频'
  //             },
  //             {
  //               value: 48,
  //               name: '用户'
  //             },
  //             {
  //               value: 25,
  //               name: '评论'
  //             },
  //             {
  //                 value: 5,
  //                 name: '演员'
  //             },
  //             {
  //                 value: 6,
  //                 name: 'vip商品'
  //             },
  //             {
  //                 value: 1,
  //                 name: '广告'
  //               },
  //               {
  //                 value: 92,
  //                 name: '订单'
  //               },
  //           ]
  //         }
  //       ]
  //   };
  var option1 = {
    series: [
      {
        type: "pie",
        data: [
          {
            value: a1,
            name: "视频",
          },
          {
            value: b1,
            name: "用户",
          },
          {
            value: c1,
            name: "评论",
          },
          {
            value: d1,
            name: "演员",
          },
          {
            value: e1,
            name: "vip商品",
          },
          {
            value: f1,
            name: "广告",
          },
          {
            value: g1,
            name: "订单",
          },
        ],
        roseType: "area",
      },
    ],
  };
  // 使用刚指定的配置项和数据显示图表。
  myChart.setOption(option);
  myChart1.setOption(option1);
}
data();
